<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>

<c:choose>
	<c:when test="${deals != nul}">
		<h2>Zamówienia ze zniżka z jaką zostały wystawione</h2>
		<p>${fn:escapeXml("#{db.(Deal join max(customer.ranks.discount))}")}</p>
		<table class="table table-hover">
			<thead>
				<tr>
					<th>Klient</th>
					<th>Koszt</th>
					<th>Zniżka</th>
				</tr>
			</thead>
			<tbody>
				<c:forEach var="item" items="${deals}">
					<tr>
						<c:forEach var="struct" items="${item}">
							<c:if test="${struct.key == 0}">
								<c:set var="deal" value="${struct.value}" />
								<!-- ${deal} -->
								<td>
									<c:out value="${deal.customer.firstName}" />
									<c:out value="${deal.customer.lastName}" />
								</td>
								<td><c:out value="${deal.cost}" /></td>
							</c:if>
							<c:if test="${struct.key == 1}">
								<td><c:out value="${struct.value}" /></td>
							</c:if>
						</c:forEach>
					</tr>
				</c:forEach>
			</tbody>
		</table>
	</c:when>
	<c:otherwise>
		<p>Sorry no data found ;(</p>
	</c:otherwise>
</c:choose>